using System;
using System.Runtime.InteropServices;

namespace Leap
{
	public class Mask : Interface
	{
		private HandleRef swigCPtr;

		public byte[] Data
		{
			get
			{
				byte[] array = new byte[Width * Height];
				DataWithArg(array);
				return array;
			}
		}

		public long SequenceId => LeapPINVOKE.Mask_SequenceId_get(swigCPtr);

		public int Id => LeapPINVOKE.Mask_Id_get(swigCPtr);

		public int Width => LeapPINVOKE.Mask_Width_get(swigCPtr);

		public int Height => LeapPINVOKE.Mask_Height_get(swigCPtr);

		public int OffsetX => LeapPINVOKE.Mask_OffsetX_get(swigCPtr);

		public int OffsetY => LeapPINVOKE.Mask_OffsetY_get(swigCPtr);

		public bool IsValid => LeapPINVOKE.Mask_IsValid_get(swigCPtr);

		public Mask(IntPtr cPtr, bool cMemoryOwn)
			: base(LeapPINVOKE.Mask_SWIGUpcast(cPtr), cMemoryOwn)
		{
			swigCPtr = new HandleRef(this, cPtr);
		}

		public static HandleRef getCPtr(Mask obj)
		{
			return obj?.swigCPtr ?? new HandleRef(null, IntPtr.Zero);
		}

		~Mask()
		{
			Dispose();
		}

		public override void Dispose()
		{
			lock (this)
			{
				if (swigCPtr.Handle != IntPtr.Zero)
				{
					if (base.swigCMemOwn)
					{
						base.swigCMemOwn = false;
						LeapPINVOKE.delete_Mask(swigCPtr);
					}
					swigCPtr = new HandleRef(null, IntPtr.Zero);
				}
				GC.SuppressFinalize(this);
				base.Dispose();
			}
		}

		public void DataWithArg(byte[] dst)
		{
			Marshal.Copy(DataPointer(), dst, 0, Width * Height);
		}

		public Mask()
			: this(LeapPINVOKE.new_Mask(), true)
		{
		}

		public IntPtr DataPointer()
		{
			return LeapPINVOKE.Mask_DataPointer(swigCPtr);
		}

		public static Mask Invalid()
		{
			return new Mask(LeapPINVOKE.Mask_Invalid(), false);
		}

		public bool Equals(Mask arg0)
		{
			bool result = LeapPINVOKE.Mask_Equals(swigCPtr, getCPtr(arg0));
			if (LeapPINVOKE.SWIGPendingException.Pending)
			{
				throw LeapPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public override string ToString()
		{
			return LeapPINVOKE.Mask_ToString(swigCPtr);
		}
	}
}
